<template>
	<view class="zone">
		<Header title="提升纪录"  color="#fff"></Header>
		<view class="main">
			<view class="box"> 
				<view class="list"> 
					<view class="item" v-for="(item ,index) in list" :key="index">
						<view class="left">
							<text>{{item.remark}}</text>
							<text>{{item.created_at}}</text>
						</view>
						<view  class="right">
							<text>+ {{item.number}}</text>
							<text v-if="item.source !== 1">-{{getxy(item.number)}}银元</text>
						</view>
					</view>
				</view>

				<view v-if="list.length==0" class="zanwu">
					<image src="http://img.cpgm.cc/panda/static/duoBao/baiwu.png" class="zaneu_img" mode="widthFix">
					</image>
					<view class="">
						没有数据哦~
					</view>
				</view>
				<u-loadmore v-else :status="status" :icon-type="iconType" :load-text="loadText" />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				list:'',
				max_page: 1,
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '没有更多了'
				},
				lucky:['',10,100,1000]
			};
		},
		onLoad(){
			this.jewelLogs();
		},
		onReachBottom() {
			if (this.page >= this.max_page) {
				this.status = 'nomore'
				return;
			}
			this.status = 'loading';
			this.page = ++this.page;
			this.jewelLogs()
			setTimeout(() => {
				if (this.page > this.max_page || this.page == this.max_page) this.status = 'nomore';
				else this.status = 'loading';
			}, 500)
		},
		methods: {
			scrolltolower() {
				// if (this.page >= this.max_page) {
				// 	this.status = 'nomore'
				// 	return;
				// }
				// this.status = 'loading';
				// this.page = ++this.page;
				// this.jewelLogs()
				// setTimeout(() => {
				// 	if (this.page > this.max_page || this.page == this.max_page) this.status = 'nomore';
				// 	else this.status = 'loading';
				// }, 500)
			},
			// 获取记录
			async jewelLogs(){
				let res = await this.$http.index.luckyLogs({
					page:this.page
				})
				this.list = [...this.list , ...res.data]
				this.max_page = res.page
				if (this.page > this.max_page || this.page == this.max_page) this.status = 'nomore';
			},

			getxy(number){
				let a = Number(number)
				if(a == 10){
					return 1
				}else if(a == 100) {
					return 10
				}else if(a == 1000) {
					return 100
				}
			},
		},
	}
</script>

<style lang="less">
.zone {
	background: #142223;
	min-height: 100vh;
}

.main {
	padding: 10px;
}

/deep/ .nav-bar {
	background: #142223;
}

.box {
}

// .scbox {
// 	height: calc(100vh - 100px);
// }


.item {
	background: rgba(0, 103, 75, 0.31);
	border-radius: 5px;
	padding: 12px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 5px 0;

	.left  {
		display: flex;
		flex-direction: column;
		
		text:nth-child(1) {
			color: #fff;
			font-size: 14px;
		}

		text:nth-child(2) {
			color: #A1A1A1;
			font-size: 12px;
			margin-top: 5px;
		}
	}

	.right {
		display: flex;
		flex-direction: column;
		align-items: center;
		
		text:nth-child(1) {
			color: #fff;
			font-size: 14px;
			font-weight: 600;
		}
		text:nth-child(2) {
			color: #fff;
			font-size: 13px;
			font-weight: 600;
			margin-top: 2px;
		}
	}
}


.zanwu {
	font-size: 14px;
	color: #A1A1A1;
	font-weight: 500;
	margin-top: 50%;
	text-align: center;

	.zaneu_img {
		width: 70%;

	}
}

</style>
